#!/bin/bash  

# 遍历所有Docker容器，但排除名为prometheus、pause、traefik的容器  
#docker ps --format "{{.Names}} {{.ID}}" | grep -vE '(prometheus|pause|traefik|enforcer) ' | while read -r container_name container_id; do
docker ps --format "{{.Names}} {{.ID}}" | while read -r container_name container_id; do
        # 检查crond 
	if docker exec "$container_id" pgrep crond >/dev/null; then
	   crond_pid=$(docker exec "$container_id" pgrep crond)
	   echo -n "crond存在于容器: $container_name with PID $crond_pid"  
	fi
        # 检查systemd 
        if docker exec "$container_id" pgrep systemd >/dev/null; then
        # 如果找到systemd进程，打印其PID和容器名称  
           systemd_pid=$(docker exec "$container_id" pgrep systemd)
           echo -n  "systemd存在于容器: $container_name with PID $systemd_pid"  
    fi
done
